﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using nyxwin.Main.Base.View;
using nyxwin.Main.ViewModel.Main;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;

namespace nyxwin.Main.View.Main
{
    public partial class MailView : MailViewBase
    {
        public MailView()
        {
            InitializeComponent();

            this.Model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Model_PropertyChanged);
        }

        void Model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Mails")
            {
                Dispatcher.BeginInvoke(() =>
                {
                    if (Model.Mails.Count > 0)
                    {
                        mailsList.ScrollIntoView(Model.Mails[0]);
                    }
                });
            }
        }

        private void NyxIcon_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Icon_Tap(sender, e);
        }
    }

    public class MailViewBase : PivotItemView<MailViewModel> { }
}
